import Vue from 'vue'
import VueRouter from 'vue-router'


// 路由懒加载
const Home = () => import('views/home/Home.vue')
const Cart = () => import('views/cart/Cart.vue')
const Profile = () => import('views/profile/Profile.vue')
const Category = () => import('views/category/Category.vue')
const Detail = () => import('../views/detail/Detail.vue')

// 安装插件
Vue.use(VueRouter)

// 创建router实例
const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/home' },
    { path: '/home', component: Home },
    { path: '/cart', component: Cart },
    { path: '/profile', component: Profile },
    { path: '/category', component: Category },
    { path: '/detail/:iid', component: Detail }
  ],
  mode: 'history'
})

export default router